import validator from '../index.js';

// 培训新增
export class Api_POST_TrainningVO_Rules {
  constructor() {
    this.name = [
      validator.required('培训名称不能为空'),
      {
        validator(rule, value, callback) {
          callback(validator.checkNameLen(value, '培训标名称数限制50字以内'));
        },
        trigger: 'blur'
      }
    ];
    this.address = [validator.required('比赛地址不能为空')];
    this.route = [
      validator.required('培训主页地址不能为空'),
      {
        validator(rule, value, callback) {
          callback(validator.checkRoute(value, '培训主页地址格式错误，格式限制字母、数字、-'));
        },
        trigger: 'blur'
      }
    ];
    this.trainningTypeId = [validator.required('培训类型不能为空', 'change')];
    this.provinceCode = [validator.required('地区选择不能为空', 'change')];
    this.cityCode = [validator.required('地区选择不能为空', 'change')];
    this.countyCode = [validator.required('地区选择不能为空', 'change')];
    this.contactPerson = [validator.required('联系人不能为空')];
    this.contactPhoneNumber = [
      validator.required('联系人电话不能为空'),
      {
        validator(rule, value, callback) {
          callback(validator.checkPhone(value, '手机号码格式错误'));
        },
        trigger: 'blur'
      }
    ];
    this.startTime = [validator.required('时间不能为空', 'change')];
    this.endTime = [validator.required('时间不能为空', 'change')];
    this.entryStartTime = [validator.required('日期不能为空', 'change')];
    this.entryEndTime = [validator.required('日期不能为空', 'change')];
    this.checkInStartTime = [validator.required('日期不能为空', 'change')];
    this.checkInEndTime = [validator.required('日期不能为空', 'change')];
    this.entryNoticeUrl = [];
    this.disclaimerNotice = [validator.required('免责声明不能为空', 'change')];
    this.regulation = [validator.required('竞赛规程不能为空', 'change')];
    this.backgroundUrl = [validator.required('培训背景不能为空', 'change')];
    this.logoUrl = [validator.required('培训logo不能为空', 'change')];
    this.coverUrl = [validator.required('培训封面图不能为空', 'change')];
  }
}

// 新增费用
export class Api_POST_CompetitionChargeVO_Rules {
  constructor() {
    this.name = [validator.required('费用名称不能为空')];
    this.amount = [
      validator.required('费用金额不能为空（例如：10, 10.5, 10.55）'),
      {
        validator(rule, value, callback) {
          callback(validator.checkPrice(value, '费用格式错误（例如：10, 10.5, 10.55）'));
        },
        trigger: 'blur'
      }
    ];
    this.parameter = [validator.required('兼项个数不能为空', 'blur')];
    this.chargeTypeCode = [validator.required('费用类型不能为空', 'change')];
  }
}

// 新增日程
export class Api_POST_CompetitionScheduleVO_Rules {
  constructor() {
    this.time = [validator.required('时间不能为空', 'change')];
    this.name = [validator.required('事件名称不能为空')];
    this.location = [validator.required('地点不能为空')];
  }
}

// 添加项目
export class SiSTKWEventsManagementCategoryCreateDTO_Rules {
  constructor() {
    this.name = [validator.required('项目名称不能为空')];
    this.during = [validator.required('比赛时间不能为空', 'change')];
    this.maxEntry = [validator.required('限制报项数量不能为空')];
    this.eventFormatCode = [validator.required('赛制不能为空', 'change')];
    this.preEventTypeCode = [validator.required('项目类型不能为空', 'change')];
    this.round_2 = [validator.required('第2轮晋级人数不能为空', 'change')];
    this.round_3 = [validator.required('第3轮晋级人数不能为空', 'change')];
    this.round_4 = [validator.required('第4轮晋级人数不能为空', 'change')];
  }
}

// 添加组别
export class SiSTKWEventsManagementEventGroupDTO_Rules {
  constructor() {
    this.name = [validator.required('组别名称不能为空')];
    this.startBirthDate = [validator.required('年龄区间开始日期不能为空', 'change')];
    this.endBirthDate = [validator.required('年龄区间结束日期不能为空', 'change')];
    this.level_m = [validator.required('男子级别不能为空')];
    this.level_w = [validator.required('女子级别不能为空')];
    this.level_n = [validator.required('具体级别不能为空')];
    this.manList = [
      {
        type: 'array',
        required: true,
        validator(rule, value, callback) {
          callback(validator.checkArrayOfNone(value, '级别拆分不能为空'));
        },
        trigger: 'blur'
      }
    ];
    this.womenList = [
      {
        type: 'array',
        required: true,
        validator(rule, value, callback) {
          callback(validator.checkArrayOfNone(value, '级别拆分不能为空'));
        },
        trigger: 'blur'
      }
    ];
    this.mixList = [
      {
        type: 'array',
        required: true,
        validator(rule, value, callback) {
          callback(validator.checkArrayOfNone(value, '级别拆分不能为空'));
        },
        trigger: 'blur'
      }
    ];
  }
}
// 修改组别
export class SiSTKWEventsManagementUpdateEventInput_Rules {
  constructor() {
    this.name = [validator.required('组别名称不能为空')];
    this.weightClassNames = [
      {
        type: 'array',
        required: true,
        validator(rule, value, callback) {
          callback(validator.checkArrayOfNone(value, '级别拆分不能为空'));
        },
        trigger: 'blur'
      }
    ];
  }
}

// 编辑竞技类成绩
export class Api_Post_CompetitiveResultVO_Rules {
  constructor() {
    this.combatScoreA = [
      validator.required('红方得分不能为空'),
      {
        validator(rule, value, callback) {
          callback(validator.checkSum(value, '得分格式错误，必须是数字'));
        },
        trigger: 'blur'
      }
    ];
    this.combatScoreB = [
      validator.required('青方得分不能为空'),
      {
        validator(rule, value, callback) {
          callback(validator.checkSum(value, '得分格式错误，必须是数字'));
        },
        trigger: 'blur'
      }
    ];
    this.playerWin = [validator.required('获胜方不能为空')];
    this.winType = [validator.required('获胜方式不能为空')];
    this.statusCode = [validator.required('比赛状态不能为空')];
  }
}

// 编辑非竞技类成绩
export class SiSTKWEventsManagementUpdateUnitResultNoneCompetitiveInput_Rules {
  constructor() {
    this.expressiveScore = [
      validator.required('表现力得分不能为空'),
      {
        validator(rule, value, callback) {
          callback(validator.checkSum(value, '得分格式错误，必须是数字'));
        },
        trigger: 'blur'
      }
    ];
    this.accuracyScore = [
      validator.required('准确率得分不能为空'),
      {
        validator(rule, value, callback) {
          callback(validator.checkSum(value, '得分格式错误，必须是数字'));
        },
        trigger: 'blur'
      }
    ];
    this.statusCode = [validator.required('比赛状态不能为空')];
    this.irmCode = [validator.required('判定方式不能为空')];
  }
}
